package com.changgou.order.listener;

import com.changgou.order.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author kfzhao
 * @version 1.0
 * @className OrderTimeoutListener
 * @description
 * @date 2022/1/5 0:33
 */
@Component
@Slf4j
public class OrderTimeoutListener {

    @Autowired
    private OrderService orderService;

    @RabbitListener(queues = "queue.ordertimeout")
    public void receiveCloseOrderMessage(String message) {
        log.info("接收到关闭订单的消息");
        log.info(message);
        try {
            // 调用业务层完成关闭订单操作
            orderService.closeOrder(message);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
